import router from "./index";
import store from "../store/index";
// import {getToken} from "@/utils/app";
const whiteRouter=['/login']
router.beforeEach((to, from, next) => {
  if (to.path==='/login'||to.path==='/'){
    next()
  }else {
    console.log(1);
    if (store.getters['getRole'].length === 0) {
      store.dispatch('getRouts').then(res => {
        console.log(res);
      })
    } else {
      next()
    }
  }





  // if(true){
  // if (from.path!="/login"||from.path!="/"){
  //   console.log("=====>",store.getters['getRole']);
  // }
  // next()
  // }else{
  //   console.log('不存在');
  //   if (whiteRouter.indexOf(to.path)!==-1){
  //     next()
  //   }else{
  //     next('/login')
  //   };
  // }
});
